import { getUserInfo } from '@/api/common/login'
export default {
	data(){
		return {
			
		}
	},
	methods: {
		async checkIsLogin(){
			const token = uni.getStorageSync("token");
			if(!token){
				return false
			}
			if(token){
				const res = await getUserInfo()
				if(res.code != 200){
					return false
				}
				uni.setStorageSync("user", res.user)
				return true
			} 
			return false
		},
		$goToPage(url){
			uni.navigateTo({
			  url: url 
			});
		},
	},
	async mounted(){
		const isLogin = await this.checkIsLogin()
		if(!isLogin){
			this.$goToPage('/pages/login/index?redirect=')
		}
	}
}